package org.jsemantic.servicerules.examples.even;

import java.util.Map;
import java.util.WeakHashMap;

import org.jsemantic.core.session.factory.SemanticSessionFactory;
import org.jsemantic.servicerules.drools.session.factory.SemanticSessionFactoryImpl;

public class EvenServiceFactory {
	
	private static SemanticSessionFactory factory = null;
	
	public static String ruleFile = "org/jsemantic/servicerules/examples/even/even.drl";

	public static EvenService getInstance() {
		EvenService service = new EvenService();
		service.setSemanticSessionFactory(getSemanticFactory());
		return service;
	}

	private static SemanticSessionFactory getSemanticFactory() {
		if (factory == null) {
			factory = new SemanticSessionFactoryImpl(
				ruleFile);
			factory.setSessionVariables(getSessionVariables());
		}
		return factory;
	}
	
	private static Map getSessionVariables() {
		Map variables = new WeakHashMap();
		variables.put("test", "test");
		return variables;
	}
	
}
